//#########################################################################
//                              WackiEngie
//           Copyright (c) 2014 Marc Wacker. All rights reserved.
//#########################################################################

#include "WeLog.h"
#include "WeTime.h"

namespace WackiEngine
{

	LogEntry::LogEntry(const String& msg, const String& channel, const String& file, uint32 line)
		: _msg(msg), _channel(channel), _file(file), _line(line)
	{ 
		_time = gTime().getTime();
	}

	Log::Log()
	{ }

	Log::~Log()
	{
		clear();
	}

	void Log::addEntry(const String& msg, const String& channel, const String& file, uint32 line)
	{
		auto entry = new LogEntry(msg, channel, file, line);
		_entries.push_back(entry);

		if(!entryAdded.empty())
			entryAdded(*entry);
	}

	void Log::clear()
	{
		for(auto entry : _entries)
			delete entry;

		_entries.clear();
	}

}